import {BasicColumn} from '@/components/Table';
import {FormSchema} from '@/components/Table';
import { rules} from '@/utils/helper/validator';
import { render } from '@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '有声书id',
    align: "center",
    dataIndex: 'id'
  }, {
    title: '小说id',
    align: "center",
    dataIndex: 'bookId',
    width:200
  },
  {
    title: '作品方向',
    align: "center",
    dataIndex: 'workDirectionText'
  },
  {
    title: '分类名',
    align: "center",
    dataIndex: 'catText',
    width:200
  },
  {
    title: '有声书名称',
    align: "center",
    dataIndex: 'bookName',
    width:300
  },
  {
    title: '音频状态',
    align: "center",
    dataIndex: 'bookStatus_dictText'
  },
  {
    title: '播放量',
    align: "center",
    dataIndex: 'playCount'
  },
  {
    title: '收藏数',
    align: "center",
    dataIndex: 'collectCount'
  },
  {
    title: '集数',
    align: "center",
    dataIndex: 'subsetCount'
  },
  {
    title: '最新集编号',
    align: "center",
    dataIndex: 'lastSubsetIndex'
  },
  {
    title: '最新集',
    align: "center",
    dataIndex: 'lastSubsetName'
  },
  {
    title: '最新集更新时间',
    align: "center",
    dataIndex: 'lastSubsetUpdateTime'
  },
  {
    title: '是否收费',
    align: "center",
    dataIndex: 'isVip',
    customRender:({text}) => {
      return  text?'是':'否'
    },
  },
  {
    title: '入库时间',
    align: "center",
    dataIndex: 'createTime'
  },
];
columns.forEach(item=>{
  item.resizable=true
})
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "分类名",
    field: 'catId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "book_category,name,id"
    },
    colProps: {span: 6},
  },
  {
    label: "有声书名称",
    field: 'bookName',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "音频状态",
    field: 'bookStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "is_completed"
    },
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '小说id',
    field: 'bookId',
    component: 'InputNumber',
  },
  {
    label: '作品方向',
    field: 'workDirection',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "work_direction"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入作品方向!'},
             ];
    },
  },
  {
    label: '分类名',
    field: 'catId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "book_category,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入分类名!'},
             ];
    },
  },
  {
    label: '有声书封面',
    field: 'picUrl',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入有声书封面!'},
             ];
    },
  },
  {
    label: '有声书名称',
    field: 'bookName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入有声书名称!'},
             ];
    },
  },
  {
    label: '有声书简介',
    field: 'bookDesc',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入有声书简介!'},
             ];
    },
  },
  {
    label: '音频状态',
    field: 'bookStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "is_completed"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入音频状态!'},
             ];
    },
  },
  {
    label: '是否收费',
    field: 'isVip',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "is_vip"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否收费!'},
             ];
    },
  },
  {
    label: '入库状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "book_status"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入入库状态!'},
             ];
    },
  },
  {
    label: '语言',
    field: 'language',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "language"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入语言!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
